<?php
/**
 * Created by JetBrains PhpStorm.
 * User: ZhangYi
 * Date: 11-9-2
 * Time: 上午8:30
 * To change this template use File | Settings | File Templates.
 */

class celebrityPkComponents extends sfComponents
{
    public function executeEntry(sfWebRequest $request)
    {
        //        $this->pk = Doctrine_core::getTable("CelebrityPK")->createQuery('c')
        //                ->addWhere('c.is_on_top_b=?', 1)->addOrderBy('c.create_time desc')->fetchOne();
        //
        //        $this->v1 = $this->pk->getCount1I() + $this->pk->getCount1MaskI();
        //        $this->v2 = $this->pk->getCount2I() + $this->pk->getCount2MaskI();
        //        $p1 = (float)$this->v1 / (float)($this->v1 + $this->v2);
        //        $p2 = (float)$this->v2 / (float)($this->v1 + $this->v2);
        //        $this->left = 100 - 90 * ($p1);
        //        $this->right = 100 - 90 * ($p2);
    }

    public function executePkbox(sfWebRequest $request)
    {
        $this->pk = Doctrine_core::getTable("CelebrityPK")->createQuery('c')
                ->addWhere('c.is_on_top_b=?', 1)->addOrderBy('c.create_time desc')->fetchOne();

        if ($this->pk != null) {
            $this->v1 = $this->pk->getCount1I() + $this->pk->getCount1MaskI();
            $this->v2 = $this->pk->getCount2I() + $this->pk->getCount2MaskI();
            $p1 = (float)$this->v1 / (float)($this->v1 + $this->v2);
            $p2 = (float)$this->v2 / (float)($this->v1 + $this->v2);
            $this->left = 100 - 90 * ($p1);
            $this->right = 100 - 90 * ($p2);
        }
    }


    public function executePkhistory(sfWebRequest $request)
    {

    }
}
